<template>
	<view>
		<view class="Demo">
			<view>
				效果演示
			</view>

			<jonej-timer ref="timer" :startTime="startTime"></jonej-timer>
		</view>
		<view class="confirm">
			<button @click="confirm">{{buttonShow?'停止':"计时"}}</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				buttonShow: false,
				startTime: new Date()
			}
		},
		methods: {
			confirm() {
				this.buttonShow = !this.buttonShow; // 切换状态

				if (this.buttonShow) {
					this.$refs.timer.startTimer(); // 启动计时
				} else {
					clearInterval(this.$refs.timer.timer); // 停止计时
					
				}

			}
		}
	}
</script>

<style>
</style>